package cn.fintecher.gis.entity;

import cn.fintecher.gis.enums.AreaUnit;
import cn.fintecher.gis.enums.CommonShow;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

/**
 * @Auther: xiaqun
 * @Description: 征地信息表
 * @Date: 16:46 2019/4/29
 */

@Data
@Entity
@Table(name = "expropriation")
@ApiModel(value = "expropriation", description = "征地信息表")
public class Expropriation extends BaseEntity {
    @ApiModelProperty(value = "名称")
    private String name;

    @ApiModelProperty(value = "类型")
    private String type;

//    @ApiModelProperty(value = "行政区域")
//    private String region;

    @ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER)
    @JoinTable(name = "expropriate_region", joinColumns = @JoinColumn(name = "expropriate_id"), inverseJoinColumns = @JoinColumn(name = "region"))
    @ApiModelProperty(notes = "行政区域")
    private Set<DistrictInfo> regions;

    @ApiModelProperty(value = "面积")
    private BigDecimal acreage;

    @ApiModelProperty(value = "单位")
    @Enumerated(EnumType.STRING)
    private AreaUnit unit;

    @ApiModelProperty(value = "描述")
    private String remark;

    @ApiModelProperty(value = "征地文号")
    private String code;

    @ApiModelProperty(value = "征地时间")
    private Date levyTime;

    @ApiModelProperty(value = "批地ID")
    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "grant_id")
    private GrantInfo grantInfo;

    @ApiModelProperty(value = "是否开启流程")
    @Enumerated(EnumType.STRING)
    private CommonShow whether;

    @ApiModelProperty(value = "图层信息")
    @OneToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "business_id")
    private BusinessLayer businessLayer;
}
